package com.example.pc.updata.DaTi;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.pc.http.API;
import com.example.pc.http.Okhttp;
import com.example.pc.updata.Api;
import com.example.pc.updata.Baes.BaseActivity;
import com.example.pc.updata.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ZongJieActivity extends BaseActivity {

    @BindView(R.id.et_titel)
    TextView etTitel;

    @BindView(R.id.btn_sub)
    Button btnSub;
    String titel;
    String stringExtra;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_zongjie);
        ButterKnife.bind(this);
        stringExtra = getIntent().getStringExtra("dati");
        etTitel.setText("本次答对" + stringExtra + "道题，共" + stringExtra + "分");

        btnSub.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                titel = etTitel.getText().toString();

                add(stringExtra);
            }


        });
    }

    public void add(String chegji) {
        API.addchengji(ZongJieActivity.this, chegji, new Okhttp.Objectcallback() {
            @Override
            public void onsuccess(String st) {
                Toast.makeText(ZongJieActivity.this, "递交成绩成功！", Toast.LENGTH_SHORT).show();
                finish();
            }

            @Override
            public void onFalia(int code, String errst) {
                Toast.makeText(ZongJieActivity.this, "网络错误", Toast.LENGTH_SHORT).show();

            }
        });
    }

}
